package edu.whu.rose.clock.kps.algorithm.sortedlists;


public class ListItem implements Comparable<ListItem> {

	private final int distance;
	private final int matched_subgraph;
	private final int matched_vertex;
//	private final int vPosition;
	private final int root;
	private final int position;
	
	public ListItem(int distance, int subgraph, int vertex, int root, int position) {
		super();
		this.distance = distance;
		this.matched_subgraph = subgraph;
		this.matched_vertex = vertex;
//		this.vPosition = vPosition;
		this.root = root;
		this.position = position;
	}
	
	public int compareTo(ListItem other) {
		if (getDistance() > other.getDistance()) {
			return 1;
		}
		else if (getDistance() < other.getDistance()) {
			return -1;
		}
		else {
			if (getMatchedSubgraph() > other.getMatchedSubgraph()) {
				return 1;
			}
			else if (getMatchedSubgraph() < other.getMatchedSubgraph()) {
				return -1;
			}
			else {
				if (getMatchedVertex() > other.getMatchedVertex()) {
					return 1;
				}
				else if (getMatchedVertex() > other.getMatchedVertex()) {
					return -1;
				}
				else {
					if (getRoot() > other.getRoot()) {
						return 1;
					}
					else if (getRoot() > other.getRoot()) {
						return -1;
					}
					else {
						return 0;
					}
				}
			}
		}
	}
	
	public boolean equals(Object obj) {
		ListItem li = (ListItem) obj;
		if (getMatchedSubgraph() == li.getMatchedSubgraph() && 
				getMatchedVertex() == li.getMatchedVertex() && 
				getRoot() == li.getRoot()) {
			return true;
		}
		else {
			return false;
		}
	}
	
	public int hashCode() {
		int result = 17;
		result = 37 * result + matched_subgraph;
		result = 37 * result + matched_vertex;
		result = 37 * result + root;
		return result;
	}

	public int getDistance() {
		return distance;
	}

	public int getMatchedSubgraph() {
		return matched_subgraph;
	}

	public int getMatchedVertex() {
		return matched_vertex;
	}

//	public int getVPosition() {
//		return vPosition;
//	}
	
	public int getRoot() {
		return root;
	}
	
	public int getPosition() {
		return position;
	}
}
